<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/8/9
 * Time: 17:36
 */

namespace app\api\controller\v1;


use app\api\validate\IDMustBePositiveInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;


class Banner
{
    /**
     *获取banner对象
     * @param $id
     * @return array|false|\PDOStatement|string|\think\Model
     * @throws BannerMissException
     */
    public function getBanner($id){
        (new IDMustBePositiveInt())->goCheck();
        $banner = BannerModel::getBannerByID($id);
        if (empty($banner)){
            throw new BannerMissException();
        }
        return $banner;
    }
}